//
//  toupiaolistCollectionViewCell.m
//  hainingOASystem
//
//  Created by michael on 2017/12/4.
//  Copyright © 2017年 czd. All rights reserved.
//

#import "toupiaolistCollectionViewCell.h"

@implementation toupiaolistCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    _label1 = [[UILabel alloc]init];
    _label1.frame = CGRectZero;
        _label1.numberOfLines = 0;

      [_label1 setFont:[UIFont systemFontOfSize:13]];
       [self.contentView addSubview:_label1];
    
       _label2 = [[UILabel alloc]init];
    _label2.frame = CGRectZero;
    _label2.numberOfLines = 0;
      [_label2 setFont:[UIFont systemFontOfSize:11]];
       [self.contentView addSubview:_label2];
          _label3 = [[UILabel alloc]init];
    _label3.frame = CGRectZero;
    _label3.numberOfLines = 0;
      [_label3 setFont:[UIFont systemFontOfSize:12]];
       [self.contentView addSubview:_label3];
  
_image = [[UIImageView alloc]init];
_image.frame = CGRectZero;
       [self.contentView addSubview:_image];
_button = [UIButton buttonWithType:UIButtonTypeCustom];
       [self.contentView addSubview:_button];

}
return self;
}
- (void)layoutSubviews{
[super layoutSubviews];
// 0 96 236
NSString *url = [NSString stringWithFormat:@"%@%@",kip,_dic[@"imageUrl"]];
[self.image sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"加载"]];
_image.frame = CGRectMake(20
, 10 , (KScreenWidth/2)-40, self.contentView.height*.7);
_label1.frame = CGRectMake(_image.left, _image.bottom, 80, 20);
_label1.textColor = [UIColor blueColor];
_label1.text = _dic[@"title"];

_label2.frame = CGRectMake(_image.right-90, _image.bottom, 40, 20);
_label2.textColor = [UIColor blackColor];
//_label2.backgroundColor = [UIColor greenColor];
_label2.text = @"投票数:";

_label3.frame = CGRectMake(_image.right-50, _image.bottom, 50, 20);
_label3.textColor = [UIColor redColor];
//_label3.backgroundColor = [UIColor redColor];
   if (![_dic[@"number"] isEqual:[NSNull null]]){
_label3.text = [NSString stringWithFormat:@"%@",_dic[@"number"]];
}
_label3.textAlignment = NSTextAlignmentRight;
_button.frame = CGRectMake(_image.left, _label1.bottom, _image.width, 30);
    [_button setTitle:@"投票" forState:UIControlStateNormal];
        _button.titleLabel.font = [UIFont systemFontOfSize: 14.0];
    [_button setImage:[UIImage imageNamed:@"爱心"] forState:UIControlStateNormal];
        [_button layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:0];
 self.button.imageEdgeInsets = UIEdgeInsetsMake(5, 40, 5,70);
[_button setBackgroundColor:[UIColor blueColor]];
}
@end
